<%@ page errorPage="/error.jsp" import=" com.ora.jsp.util.*, java.util.*, de.cdot.giveaword.Word, de.cdot.util.StringFormat"%> <%-- --%> <%! /** give a word feature v4.3 (c) christof hoeke 040731 */ String[] WHATTOGET = { "id", "word", "date", "name" }; final int NUMBER = 2000; //180; //parse an integer, @param string parameter, returns a positive integer if available, else -1 public int parseInt(String p) { int r = -1; try { r = Integer.parseInt(p); } catch(Exception e) { } return r; } //parse a string, @param string parameter, returns value or empty string public String parseString( String p ) { if (p != null) return p; return ""; } %> <% //parse word String rawNewWord = parseString(request.getParameter("newword")); String newWord = StringFormat.toXMLString(rawNewWord); //parse name String rawNewName = parseString(request.getParameter("newname")); String newName = StringFormat.toXMLString(rawNewName); //parse id int lastId = parseInt(request.getParameter("lastid")); int latestDbId = giveaword.getLastId(); int newid = -1; String errormsg = ""; if (newWord.length() > 0) { //is it really newest? - put in db if (latestDbId == lastId) { if (rawNewName == null) rawNewName = ""; // REMOVED! /// latestDbId = giveaword.addNewWord(rawNewWord, rawNewName); newid = latestDbId; newWord = ""; } //from home else if (lastId == 0) { errormsg = "you want to keep your word?"; } //too late else { errormsg = "someone else was faster than you... please give a new word"; } } else { //empty if not direct link if (request.getParameter("newword") != null) errormsg = "no word given"; } //parse page boolean isLastPage = false; int lastPageId = giveaword.getNumberOfPages(NUMBER) - 1; int showPage = parseInt(request.getParameter("page")); if (showPage < 0 || showPage == lastPageId) { showPage = lastPageId; //current page to show, default is the last isLastPage = true; } //get old words Word[] word = giveaword.getPagedWords(WHATTOGET, showPage, NUMBER); %> give-a-word - cdot.de

give-a-word

a story written by visitors (ended to the amount of spam)


<% for (int i=0; i <= lastPageId; i++) { /*if (i == showPage) { %> <%=i + 1 %> <% } else { %> <%=i + 1 %> <% } */ } %>

<% if (showPage > 0 || showPage < 0) { %> (...) <% } %> <% try { for (int i = 0 ; i < word.length ; i++) { if (word[i].word == null) break; %> title=" written <% if ( word[i].name != null && word[i].name.length() > 0) { %>by <%=word[i].name %> <% } %><%=word[i].date %> " onmouseover="showWordInfo(this);" onmouseout="clearWordInfo();"><%=word[i].word %> <% } } catch (NullPointerException e) {} %> <% if (showPage >= 0 && !isLastPage) { %> (...) <% } %>

<% /* if (isLastPage) { %>

<%=errormsg %>



<% } */%>